package com.pyb.utils;

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

/**
 * @version 1.0
 * @Author 彭彦彬
 * @Date 2025/1/15 15:55
 * @注释
 */
public class FileScanner {

    public static List<String> listFiles(String directoryPath) {
        List<String> fileList = new ArrayList<>();
        Path path = Paths.get(directoryPath);
        File dir = path.toFile();

        if (dir.exists() && dir.isDirectory()) {
            File[] files = dir.listFiles();
            if (files != null) {
                for (File file : files) {
                    if (file.isFile()) {
                        fileList.add(file.getName());
                    }
                }
            }
        }

        return fileList;
    }
}
